<?php
namespace App\Event\User;

use App\Event\Event;
use App\Repository\UserRepository;
use App\Repository\ShopRepository;
use App\Repository\LevelRepository;

// 创建用户事件
class CreateEvent extends Event
{
    public $user;
    
    public $toUser;
    
    public $shop;
    
    public $level;
    
    // 用户及金额
    public function __construct($user)
    {
        $this->user = $user;
        
        // 上级用户
        if($user = $this->user->user)
        {
            $this->toUser = UserRepository::make($user);
        }
        
        // 上级的店铺
        if($user = $this->user->user)
        {
            if($user->shop)
            {
                $this->shop = ShopRepository::make($user->shop);
            }
        }
    }
}